package com.suny.example;

/**
 * @author sunny
 * @date 2019/4/25
 */
public class DaemonThread {

    public static void main(String[] args) {
        UnDaemonClass a = new UnDaemonClass();
        InnerDaemonClass b = new InnerDaemonClass();
        b.setDaemon(true);

        a.start();
        b.start();

        System.out.println((15 % 11) + " : " + (15 & 10));
        System.out.println((40 % 35) + " : " + (40 & 34));
    }

    private static class UnDaemonClass extends Thread {
        @Override
        public void run() {
            for (int i = 0; i < 5; i++) {
                System.out.println("非守护线程-------: " + i);
                try {
                    Thread.sleep(7);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private static class InnerDaemonClass extends Thread{

        @Override
        public void run() {
            for (int i = 0; i < 5000; i++) {
                System.out.println("守护线程------");
                try {
                    Thread.sleep(7);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
